﻿using Siasun.AFC.RtPlatfromGui.IBll.IServer;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace Siasun.AFC.RtPlatfromGui.UI.Converters
{
    class MenuDataConverters : IValueConverter
    {
        IMenuDataServer menuDataServer = ServerFactory.CreateMenuDataServer();

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (object.Equals(null, value)) return "查询失败";

            string parentId = value.ToString();
            IBll.Model.MenuInfo menuInfo = menuDataServer.GetMenuData(parentId);
            if (object.Equals(null, menuInfo) || string.IsNullOrEmpty(menuInfo.Id)) return "查询失败";

            return menuInfo.MenuName;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //throw new NotImplementedException();
            return null;
        }
    }
}
